package com.deep.stream.controller;

import com.deep.stream.models.OrganizationChangeModel;
import com.deep.stream.service.SimpleSink;
import com.deep.stream.service.SimpleSourceBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dell
 * @create 2022/7/29 15:37
 */
@Slf4j
@RestController
@EnableBinding(Sink.class)
public class TestController {

    @Autowired
    SimpleSourceBean simpleSourceBean;

    @GetMapping("/send")
    public String send() {
        simpleSourceBean.publish("test");
        return "send done";
    }

    @StreamListener(Sink.INPUT)
    public void receive(String msg) {
        log.info("test: {}", msg);
    }
}
